package com.deyuanyun.pic.pipe.controller.vo;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.common.util.format.NumberFormat;
import com.deyuanyun.pic.pipe.domain.Closure;
import com.deyuanyun.pic.pipe.domain.Cross;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 套管信息表
 */
public class CrossVO extends BaseVO<Cross> {

    // 管道名称
    private String pipeLineName;
    // 所属穿跨越
    private String pipePipecrossName;
    // 起点绝对距离(m)
    private String fromMileage;
    // 起点相对最近参考点
    private String fromReference;
    // 起点相对最近参考点距离(m)
    private String fromReferenceDistance;
    // 终点绝对距离(m)
    private String toMileage;
    // 终点相对最近参考点
    private String toReference;
    // 终点相对最近参考点距离(m)
    private String toReferenceDistance;
    // 套管长度（m）
    private String casingLength;
    // 是否已填充
    private String filledind;
    // 套管壁厚（mm）
    private String wallThickness;
    // 直径（mm）
    private String diameter;
    // 密封类型
    private String sealtype;
    // 是否绝缘：0：是；1：否
    private String insulatorind;
    // 是否短接：0：是；1：否
    private String shortedind;
    // 是否已排空：0：是；1：否
    private String ventedind;
    // 套管类型
    private String casingType;
    // 防腐材料
    private String antisepticMaterial;
    // 填充材料
    private String fillMaterial;

    // 链接GIS结果表
    private String gisId;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getPipePipecrossName() {
        return pipePipecrossName;
    }

    public void setPipePipecrossName(String pipePipecrossName) {
        this.pipePipecrossName = pipePipecrossName;
    }

    public String getFromMileage() {
        return fromMileage;
    }

    public void setFromMileage(String fromMileage) {
        this.fromMileage = fromMileage;
    }

    public String getFromReference() {
        return fromReference;
    }

    public void setFromReference(String fromReference) {
        this.fromReference = fromReference;
    }

    public String getFromReferenceDistance() {
        return fromReferenceDistance;
    }

    public void setFromReferenceDistance(String fromReferenceDistance) {
        this.fromReferenceDistance = fromReferenceDistance;
    }

    public String getToMileage() {
        return toMileage;
    }

    public void setToMileage(String toMileage) {
        this.toMileage = toMileage;
    }

    public String getToReference() {
        return toReference;
    }

    public void setToReference(String toReference) {
        this.toReference = toReference;
    }

    public String getToReferenceDistance() {
        return toReferenceDistance;
    }

    public void setToReferenceDistance(String toReferenceDistance) {
        this.toReferenceDistance = toReferenceDistance;
    }

    public String getCasingLength() {
        return casingLength;
    }

    public void setCasingLength(String casingLength) {
        this.casingLength = casingLength;
    }

    public String getFilledind() {
        return filledind;
    }

    public void setFilledind(String filledind) {
        this.filledind = filledind;
    }

    public String getWallThickness() {
        return wallThickness;
    }

    public void setWallThickness(String wallThickness) {
        this.wallThickness = wallThickness;
    }

    public String getDiameter() {
        return diameter;
    }

    public void setDiameter(String diameter) {
        this.diameter = diameter;
    }

    public String getSealtype() {
        return sealtype;
    }

    public void setSealtype(String sealtype) {
        this.sealtype = sealtype;
    }

    public String getInsulatorind() {
        return insulatorind;
    }

    public void setInsulatorind(String insulatorind) {
        this.insulatorind = insulatorind;
    }

    public String getShortedind() {
        return shortedind;
    }

    public void setShortedind(String shortedind) {
        this.shortedind = shortedind;
    }

    public String getVentedind() {
        return ventedind;
    }

    public void setVentedind(String ventedind) {
        this.ventedind = ventedind;
    }

    public String getCasingType() {
        return casingType;
    }

    public void setCasingType(String casingType) {
        this.casingType = casingType;
    }

    public String getAntisepticMaterial() {
        return antisepticMaterial;
    }

    public void setAntisepticMaterial(String antisepticMaterial) {
        this.antisepticMaterial = antisepticMaterial;
    }

    public String getFillMaterial() {
        return fillMaterial;
    }

    public void setFillMaterial(String fillMaterial) {
        this.fillMaterial = fillMaterial;
    }

    public String getGisId() {
        return gisId;
    }

    public void setGisId(String gisId) {
        this.gisId = gisId;
    }

    public void fromDomain(Cross domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }
        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 所属穿跨越
        this.pipePipecrossName = domain.getPipePipecrossId();
        // 起点绝对距离(m)
        this.fromMileage = NumberFormat.format(domain.getFromMileage(), NumberFormat.FMT_PLACES3);
        // 起点相对最近参考点
        this.fromReference = domain.getFromReference();
        // 起点相对最近参考点距离(m)
        this.fromReferenceDistance = NumberFormat.format(domain.getFromReferenceDistance(), NumberFormat.FMT_PLACES3);
        // 终点绝对距离(m)
        this.toMileage = NumberFormat.format(domain.getToMileage(), NumberFormat.FMT_PLACES3);
        // 终点相对最近参考点
        this.toReference = domain.getToReference();
        // 终点相对最近参考点距离(m)
        this.toReferenceDistance = NumberFormat.format(domain.getToReferenceDistance(), NumberFormat.FMT_PLACES3);
        // 套管长度（m）
        this.casingLength = NumberFormat.format(domain.getCasingLength());
        // 是否已填充
        this.filledind = convert(domain.getFilledind());
        // 套管壁厚（mm）
        this.wallThickness = NumberFormat.format(domain.getWallThickness());
        // 直径（mm）
        this.diameter = NumberFormat.format(domain.getDiameter());
        // 密封类型
        this.sealtype = CodeUtil.getName(domain.getSealtype());
        // 是否绝缘：0：是；1：否
        this.insulatorind = convert(domain.getInsulatorind());
        // 是否短接：0：是；1：否
        this.shortedind = convert(domain.getShortedind());
        // 是否已排空：0：是；1：否
        this.ventedind = convert(domain.getVentedind());
//        // 是否绝缘：0：是；1：否
//        this.insulatorind = domain.getInsulatorind();
//        // 是否短接：0：是；1：否
//        this.shortedind = domain.getShortedind();
//        // 是否已排空：0：是；1：否
//        this.ventedind = domain.getVentedind();
        // 套管类型
        this.casingType = CodeUtil.getName(domain.getCasingType());
        // 防腐材料
        this.antisepticMaterial = CodeUtil.getName(domain.getAntisepticMaterial());
        // 填充材料
        this.fillMaterial = CodeUtil.getName(domain.getFillMaterial());
        // gis地址
        this.gisId = domain.getGisId();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordtime(), domain.getCreateRemark());
    }

    public Page<CrossVO> fromDomainList(Page<Cross> domainList) {
        Page<CrossVO> list = new Page<CrossVO>();
        for (Cross closure : domainList) {
            CrossVO crossVO = new CrossVO();
            crossVO.fromDomain(closure);
            list.add(crossVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }

}